# coding=utf8
import glgui2
import GameLogic
import GameRender
import Map
import Mission

class guiGame:
  def show(self):
    self.layout.visible = True
    self.hide_menu(None)
  def hide(self):
    self.layout.visible = False
    
  def show_menu(self,sender):
      self.menu.visible = True
  
  
  def hide_menu(self,sender):
      self.menu.visible = False
      
       
  def __init__(self):
    self.layout = glgui2.Layout((1024,768))
    self.incoset = GameRender.Iconset()
    self.layout.add_widget(glgui2.Button('game/show_menu',u'Меню',pos = (900,10)))
    glgui2.common_signals.connect_to_channel('gui_events/on_click/game/show_menu',self.show_menu)
    
    self.map = Map.Map('game')
    #self.map.load('test.map')
    self.mission = Mission.Mission(self.map)
    #self.mission.load('test.mis')

    #Menu1
    self.menu_layout = glgui2.CentralLayout((320,160))
    self.menu = glgui2.Frame('menu',layout = self.menu_layout,pos = (350,400),size = (320,160))
    self.menu.layout.add_widget(glgui2.Button('game/menu/continue',u'Продолжить'))
    glgui2.common_signals.connect_to_channel('gui_events/on_click/game/menu/continue',self.hide_menu)
    self.menu.layout.add_widget(glgui2.Button('game/menu/quit',u'Выйти'))
    
    self.menu.visible = False
    self.layout.add_widget(self.menu)
    
    #Operational command frame
    
    self.operational_menu = glgui2.Frame(u'Операция',pos = (50,30),size = (250,100),layout = glgui2.CentralLayout((200,140)))
    
    #Tactical command frame
    
    self.tactical_menu = glgui2.Frame(u'Тактика',pos = (320,30),size = (250,100),layout = glgui2.CentralLayout((200,140)))
    
    self.layout.add_widget(self.tactical_menu)
    self.layout.add_widget(self.operational_menu)
    
    self.layout.update_rect()

    
  def draw(self):
    self.map.draw()
    self.layout.draw()

class Player:
  def __init__(self,name,side,input):
    self.name = name
    self.side = side
    self.input = None
    self.plan = None
    
  def set_plan(self,plan):
    self.plan = plan
    
class GameMain:
  def __init__(self):
    self.map = None
    self.mission = mission
    self.side = side
    self.time = 0#counts the quantum of time. Should be increased only by 1.

  def set_map(self,map):
    pass
  def set_mission(self,map):
    pass
  def set_controls(self):
    pass
  def make_step(self):
    pass
